package com.lc.es.controller;

import com.lc.es.service.PositionService;
import com.lc.es.vo.PageRequest;
import com.lc.es.vo.PageResult;
import com.lc.es.vo.PositionRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author liuc
 * @date 2021/8/31
 * @description
 **/
@Controller
public class PositionController {
    @Autowired
    private PositionService service;

    @GetMapping({"/","/index"})
    public   String  indexPage(){
        return "index";
    }


    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
    @ResponseBody
    public List<Map<String,Object>> searchPosition(@PathVariable("keyword") String  keyword, @PathVariable("pageNo")int pageNo,
                                                   @PathVariable("pageSize")int  pageSize)throws IOException {
        PositionRequest request = new PositionRequest();
        request.setContent(keyword);
        request.setPageNo(pageNo);
        request.setPageSize(pageSize);
        PageResult<Map<String, Object>> page = service.page(request);
        return page.getData();
    }
}
